#ifndef _NETWORK_H_
#define _NETWORK_H_

#define MAX_REQUEST_SIZE 8192
#define MAX_RESPONSE_SIZE 8192

struct _Client {
	int socket;
	pthread_t thread;
	socklen_t size;
	struct sockaddr_in address;
	uint32_t id;
};

/*
struct _NetworkReceiveArg {
	Controller *controller;
	Client *client;
};
*/

struct _Network {
	Controller *controller;
	GList *clients;
	int socket;
	pthread_t thread;
	struct sockaddr_in address;
	socklen_t size;
	uint16_t port;
	uint32_t connections;
};

Network * network_new(Controller *);

void network_start(Network *);

void network_stop(Network *);

void network_accept(Network *);

void network_receive(Controller *, Client*);

//void * network_receive(void *);

void network_send_response(Client *, char *);

void network_send_error_500(Client *);

void network_free_client(gpointer);

#include "Network.c"
#endif
